<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>返回由类的方法名组成的数组</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.get-class-methods" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">get_class_methods</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">get_class_methods</span> &mdash; <span class="dc-title">返回由类的方法名组成的数组</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.get-class-methods-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>get_class_methods</strong></span>
    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$class_name</code></span>
   ) : <span class="type">array</span></div>

  <p class="para rdfs-comment">
   返回由类的方法名组成的数组。
  </p>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-function.get-class-methods-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">class_name</code></dt>

     <dd>

      <p class="para">
       类名或者对象实例。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.get-class-methods-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回由 <code class="parameter">class_name</code>
   指定的类中定义的方法名所组成的数组。如果出错，则返回 <strong><code>NULL</code></strong>。
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.get-class-methods-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-6134">
    <p><strong>Example #1 <span class="function"><strong>get_class_methods()</strong></span> 示例</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">myclass&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;constructor<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">myclass</span><span style="color: #007700">()<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return(</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;method&nbsp;1<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">myfunc1</span><span style="color: #007700">()<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return(</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;method&nbsp;2<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">myfunc2</span><span style="color: #007700">()<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return(</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #0000BB">$class_methods&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">get_class_methods</span><span style="color: #007700">(</span><span style="color: #DD0000">'myclass'</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;or<br /></span><span style="color: #0000BB">$class_methods&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">get_class_methods</span><span style="color: #007700">(new&nbsp;</span><span style="color: #0000BB">myclass</span><span style="color: #007700">());<br /><br />foreach&nbsp;(</span><span style="color: #0000BB">$class_methods&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$method_name</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$method_name</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
myclass
myfunc1
myfunc2
</pre></div>
    </div>
   </div>
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.get-class-methods-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="get_class.html" class="function" rel="rdfs-seeAlso">get_class()</a> - 返回对象的类名</span></li>
    <li class="member"><span class="function"><a href="get_class_vars.html" class="function" rel="rdfs-seeAlso">get_class_vars()</a> - 返回由类的默认属性组成的数组</span></li>
    <li class="member"><span class="function"><a href="get_object_vars.html" class="function" rel="rdfs-seeAlso">get_object_vars()</a> - 返回由对象属性组成的关联数组</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>